{ Summer Informatics School.
  Problemset: http://agul-problems1.googlecode.com/svn/trunk/2010-2011/sis/problemset11.pdf
  Problem N
  Points: 100
}
var r,i,m,n:longint; s,t:string;
begin
readln(s);
readln(t);
m:=length(t);
n:=length(s);
r:=n+m;
for i:=1 to m do
  if (copy(t,1,i)=copy(s,n-i+1,i)) and (n+m-i<r) then r:=n+m-i;
for i:=1 to n do
  if (copy(s,1,i)=copy(t,m-i+1,i)) and (n+m-i<r) then r:=n+m-i;
write(r);
end.
